
from time import sleep

from selenium import  webdriver
driver=webdriver.Firefox()
driver.get('https://www.baidu.com/')

key_word=driver.find_element_by_name('wd').send_keys('163邮箱')
bt=driver.find_element_by_id('su').click()
sleep(3)

driver.find_element_by_partial_link_text('163网易免费邮').click()

hds = driver.window_handles
sleep(5)

driver.switch_to.window(hds[1])

iframe = driver.find_element_by_xpath('/html/body/div[2]/div[3]/div/div[3]/div[4]/div[1]/div[1]/iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_name('email').send_keys('jizhidouzi')
driver.find_element_by_name('password').send_keys('doudou!')
driver.find_element_by_id('dologin').click()
sleep(3)

driver.switch_to.default_content()

driver.find_element_by_xpath("//*[@id='dvNavTop']/ul/li[2]/span[2]").click()

driver.find_element_by_class_name('nui-editableAddr-ipt').send_keys('ma_linpop@163.com')

driver.find_element_by_xpath("//*[@class='nui-ipt-input'and @type = 'text' and @tabindex = '1']").send_keys('化工学院_计171班_曲经韬  自动化发送邮件')  # 添加主题

driver.switch_to.frame(
    driver.find_element_by_xpath("//iframe[contains(@class,'APP-editor-iframe')]"))

driver.find_element_by_class_name("nui-scroll").send_keys('吃葡萄不吐葡萄皮')
driver.switch_to.default_content()  # 退出frame

driver.find_element_by_xpath("//*[@class='nui-toolbar-item']/div/span[2]").click()

sleep(5)





